package org.example.mvnrepo;

import cn.hutool.core.io.FileUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;

/**
 * @author zhangjg
 * @desc copy 拷贝源仓库 到 目标仓库
 * @date 2023/03/02 15:51
 **/
public class CopyRepo {

    private static final Logger log = LoggerFactory.getLogger(CopyRepo.class);

    public static void main(String[] args) {

        File file = new File("D:\\repository\\io\\confluent");
        String sourceDirPref = "D:\\repository";
        String targetDirPref = "D:\\testrepo";
        list(file,sourceDirPref,targetDirPref);
    }


    private static void list(File file,String sdir,String tdir){
        File[] fs = file.listFiles();
        for (File f : fs){
            if(f.isDirectory()){
                list(f,sdir,tdir);
            }else {
                log.info(f.getPath());
//                FileUtil.mkParentDirs(f.getPath().replace(sdir,tdir));
                FileUtil.copy(f.getPath(),f.getPath().replace(sdir,tdir),true);
            }
        }
    }

}
